package liu.zhi.peng;

//import java.lang.classfile.Signature;

import java.util.Random;

//import java.util.Enumeration;
//import java.util.Properties;
//import java.util.Random;
//
//public class demo13 {
//    public static void main(String[] args){
//        String str = new String("liuzhipeng");
//        System.out.println(str.length());
//        System.out.println(str.charAt(0));
//        System.out.println(str.indexOf('p'));
////        System.out.println(str.indexOf('o'));
//        System.out.println(str.equals("liuzhippng"));
//        System.out.println(str.compareTo("liuzhipeng"));
//        System.out.println(str.compareToIgnoreCase("LIUZHIPENG"));
//        System.out.println(str.contains("liu"));
//        System.out.println(str.toUpperCase());
//        System.out.println(str.toCharArray());
//        System.out.println(String.valueOf(123));
//        System.out.println(Integer.getInteger("123"));
//        Enumeration a = new Enumeration();
//        Properties properties = new Properties();
//        Enumeration propertyNames = properties.propertyNames();
//        while (propertyNames.hasMoreElements()){
//            String key = (String) propertyNames.nextElement();
//            String value = properties.getProperty(key);
//            System.out.println(key + "=" + value);
//        }
//        System.out.println(Math.PI);
//        Random r = new Random();
//        boolean a = r.nextBoolean();
//        System.out.println(a);
//        Runtime run = Runtime.getRuntime();
//    }
//}
//class Person1{
//    private String name;
//    private int age;
//    public Person1(String name, int age){
//        this.name = name;
//        this.age = age;
//    }
//    @Override
//    public String toString() {
//        return "姓名"+this.name;
//    }
//    public  void finalize() throws Throwable {
//        System.out.println("hh"+this);
//    }
//
//}
//public class demo13{
//    public static void main(String[] args){
//        System.gc();
//        Scanner sc  = new Scanner(System.in);
//        char []arr = new char[5];
//        for(int i=0;i<arr.length;i++)
//        {
//            arr[i]=sc.nextLine().charAt(0);
//        }
//        for(char a:arr)
//            System.out.println(a);
//        System.out.println(arr.toString());
//        String str = "liuzhipe";
//        arr=str.toCharArray();
//        for (int i = 0; i < arr.length; i++) {
//            System.out.println(arr[i]);
//        }
//        System.out.println(arr.toString());
//        System.out.println(arr.length);
//        System.out.println(arr[9]);
//        System.out.println(1);
        //各位数求和
//        int n;
//        Scanner sc = new Scanner(System.in);
//        n = sc.nextInt();
//        int sum=0;
//        while(n>0)
//        {
//            sum+=n%10;
//            n/=10;
//        }
//        System.out.println(sum);
        //数组中找最大值
//        int [] arr = new int [10];
//        Random ran = new Random();
//        for (int i = 0; i < 10; i++) {
//            arr[i] = ran.nextInt(0,21);
//        }
//        int max = 0;
//        for (int i = 0; i < arr.length; i++) {
//            if(arr[i]>arr[max])
//                max = i;
//        }
//        System.out.println(Arrays.toString(arr));
//        System.out.println(max);
//        System.out.println(arr[max]);
        //求1000以内的完数
//        int n;
//        Scanner sc = new Scanner(System.in);
//        n = sc.nextInt();
//        int sum=0;
//
//            for(int i=1;i<=Math.sqrt(n);i++)
//            {
//                if(n%i==0)
//                {
//                    sum+=i;
//                    if(i!=1)
//                        sum+=n/i;
//                }
//            }
//            if(sum==n)
//                System.out.println(n+"是一个完数");
//            else System.out.println(n+"不是一个完数");
//            sum=0;
/*        public class demo13{
            public static void main(String[] args){
                int []arr1={1,2,3,5,6,8,9,9};
                int []arr2={0,2,3,5,5,7,8};
                Arrays.sort(arr1);
                Arrays.sort(arr2);
                System.out.println(Arrays.toString(arr1));
                System.out.println(Arrays.toString(arr2));
                System.out.println(Arrays.toString(sort(arr1, arr2)));

            }
    public static int [] reduce(){
                int n=5+new Random().nextInt(6);
                int [] arr = new int [n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = new Random().nextInt(11);
        }
        return arr;
    }
    public static int[] sort(int [] arr1,int [] arr2)
    {
        int n=arr1.length+arr2.length;
        int []arr = new int[n];
        int k=0;
        int j=0;
        int i=0;
        while(k<arr1.length&&j<arr2.length) {
            if(arr1[k]>arr2[j])
            {
                arr[i++]=arr2[j++];
            }
            else if(arr1[k]<arr2[j])
            {
                arr[i++]=arr1[k++];
            }
            else {
                arr[i++]=arr1[k++];
            }
        }
        int b= k>=arr1.length ? j : k;
        int []arr3= k>=arr1.length ? arr2 : arr1;
        for(int p=i;p<n;p++)
        {
            arr[p]=arr3[b++];
        }
        return arr;
    }
}*/
//public class demo13{
//    public static void main(String[] args)throws Exception
//    {
//        int []arr={1,2,3,4,5};
//        int []array=new int [arr.length];
//                System.arraycopy(arr,0,array,0,arr.length);
//        System.out.println(Arrays.toString(array));
//        Runtime ran = Runtime.getRuntime();
//        System.out.println(ran.maxMemory());
//        System.out.println(ran.totalMemory());
//        System.out.println(ran.freeMemory());
//        ran.exec("notepad");
//        BigInteger big = new BigInteger("111222333444555666");
//        BigInteger small = new BigInteger("222333444555666777888");
//        BigInteger []arr =small.divideAndRemainder(big);
//        System.out.println(arr[0]+"和"+arr[1]);
//        BigDecimal big = new BigDecimal("111");
//        Date data = new Date();
//        System.out.println(data.toString());
//    }
//}
//随机打印图形
//public class demo13{
//    public static void main(String[] args){
//        Random ran  = new Random();
//        int n;
//        for(int i = 0;i<10;i++)
//        {
//            n=ran.nextInt(3)+1;
//            if(n==1)
//            {
//                Shape sh = new Orical();
//                sh.print();
//            }
//            else if(n==2)
//            {
//                Shape sh = new Fang();
//                sh.print();
//            }
//            else
//            {
//                Shape sh = new Ling();
//                sh.print();
//            }
//
//        }
//    }
//}
// class Shape{
//    public  void print(){
//
//    }
//    public void ln()
//    {
//        System.out.println();
//    }
//}
//class Orical extends Shape{
//    public void print(){
//        System.out.println("打印了一个圆形！");
//    }
//}
//class Fang extends Shape{
//    public void print(){
//        System.out.println("打印了一个正方形！");
//    }
//}
//class Ling extends Shape{
//    public void print(){
//        System.out.println("打印了一个菱形！");
//    }
//}
//面向对象-》士兵和枪
public class demo13{
    public static void main(String[] args){
        Ak47 ak = new Ak47(1000,"good",10);
        soldier sol = new soldier("zhangsan",22,'男',50,ak);
        sol.go();
        sol.attack();
        sol.getter();
        sol.printAk47();
    }
}
class soldier{
   private String name;
   private int age;
    private char sex;
    private int enouage;
    Ak47  tor;
    public void go(){
        System.out.println("士兵正在前进");
    }
    public void attack(){
        if(enouage<10)
        System.out.println("士兵需要休息");
        else
            System.out.println("士兵可以进攻");
    }
    public soldier(String name ,int age ,char sex,int enouage,Ak47 tor){
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.enouage = enouage;
        this.tor = tor;
    }
    public void getter()
    {
        System.out.println("士兵的姓名是"+name+"士兵的能量是"+enouage);
    }
    public void printAk47()
    {
        tor.getter();
    }
    public void setter(String name ,int age ,char sex,int enouage,Ak47 tor){
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.enouage = enouage;
        this.tor = tor;
    }
    public soldier(){

    }
}
class Ak47{
    int num;
    String name;
    int sum;
    public Ak47(int num,String name ,int sum){
        this.num = num;
        this.name = name;
        this.sum = sum;
    }
    public void getter()
    {
        System.out.println("枪里面的子弹一共还有"+num+"发");
        System.out.println("枪的状态是"+name);
        System.out.println("枪现在还有"+sum+"把");
    }
    public void setter(int num,String name ,int sum)
    {
        this.num = num;
        this.name = name;
        this.sum = sum;
    }
    public Ak47(){

    }
}